{% extends "layout.html" %}
{% load static %}

{% block CSS %}
    <style>
        .center-container {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            height: auto; /* 页面高度的80% */
            font-family: Arial, sans-serif;
            margin: auto; /* 在页面中居中 */
            position: relative; /* 添加绝对定位 */
            top: 10px;

        }

        .styled-form {
            margin: 20px;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            background-color: #eee9b6;
        }

        .form-group {
            align-items: center;
            margin-bottom: 15px;
        }

        .form-label {
            display: block;
            font-weight: bold;
        }

        .tags-group #id_tags {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
        }

        .form-group .tags-group label {
            margin-right: 10px;
        }

        .form-group.tags-group .form-check {
            margin-right: 15px;
            display: inline-block;
        }

        .form-group.tags-group .form-check-label {
            margin-left: 5px;
        }


        .error-message {
            color: red;
        }

        .submit-button {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            background-color: #337ab7;
            color: #fff;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .submit-button:hover {
            background-color: #23527c;
        }
    </style>
{% endblock %}

{% block content %}
    <div class="center-container">
        <form method="post" novalidate class="styled-form"> <!-- 添加自定义样式类名 -->
            {% csrf_token %}
            {% for field in PostForm %}
                <div class="form-group">
                    <label class="form-label"> {{ field.label }} </label>
                    <br>
                    {% if field.name == 'tags' %}
                        <div class="tags-group">{{ field }}</div>
                    {% else %}
                        {{ field }}
                    {% endif %}
                    <span class="error-message">{{ field.errors.0 }}</span>
                </div>
            {% endfor %}
            <button type="submit" class="btn btn-primary submit-button"> 发 布</button>
            <span class="error-message">{{ error_message }}</span>
        </form>
    </div>
{% endblock %}
